$(document).ready(function() {
   $('#notifications').hide();

    var options = { 
        target:        '#notifications',   // target element(s) to be updated with server response 
 				url: 'process.php',
				type: 'post',
				//dataType: 'xml',
				beforeSubmit:  showRequest,  // pre-submit callback 
        success:   showResponseAddLink,
    }; 

    $('#addLinkForm').submit(function() { 
        $(this).ajaxSubmit(options);  
        return false; 
    });

});


$(document).ready(function() {
    var options = { 
        target:        '#notifications',   // target element(s) to be updated with server response 
 				url: 'process.php',
				type: 'post',
				//dataType: 'xml',
				beforeSubmit:  showRequest,  // pre-submit callback 
        success:   showResponseAddCategory,
				
    }; 

    $('#addCategoryForm').submit(function() { 
        $(this).ajaxSubmit(options);  
        return false; 
    });

});


/*$(document).ready(function() {
	$('#category-links a').click(function() {
		$("#links").hide().load('process.php', {'list_links_for_category': $(this).text()}, function() {
			$(this).fadeIn('slow');
		});
		return false;
	});
});
*/
$(document).ready(function() {
	$('a.delete-link').click(function() {
		$("#links").hide().load('process.php', {'delete_link': 'true'}, function() {
			$(this).fadeIn('fast');
		});
		return false;
	});
});


// pre-submit callback 
function showRequest(formData, jqForm, options) {
    var queryString = $.param(formData); 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
	$('#notifications').fadeIn("slow");
  //$('#notifications').show();
 	//$('#url').empty();
}

function showResponseAddLink(responseText, statusText)  { 
	$('#notifications').fadeIn("slow");
  //$('#notifications').show();
	$("#addLinkForm").resetForm();
	$("#links").hide().load('process.php', {'load_link_list': 'true'}, function() {
		$(this).fadeIn('fast');
	});
}

function showResponseAddCategory(responseText, statusText)  { 
	$('#notifications').fadeIn("slow");
  //$('#notifications').show();
	$("#addCategoryForm").resetForm();
	$("#category").hide().load('process.php', {'load_category_selectbox': 'true'}, function() {
		$(this).fadeIn('fast');
	});
	$("#categoryFilter").hide().load('process.php', {'load_category_selectbox': 'true'}, function() {
		$(this).fadeIn('fast');
	});
	$("#categories").hide().load('process.php', {'list_categories': 'true'}, function() {
		$(this).fadeIn('slow');
	});
}
